
Ext.define('Holo.model.Spot', {
    extend: 'Ext.data.Model',

    idProperty: 'id',

    fields: [
        {
            name: 'id',
            type: 'int'
        },
        {
            name: 'id_text',
            type: 'string',
	},
        {
            name: 'name',
            type: 'string'
        },
        {
            name: 'type',
            type: 'string'
        },
        {
            name: 'phone',
            type: 'string'
        },
        {
            name: 'adress_text',
            type: 'string'
        },
        {
            name: 'gps_x',
            type: 'string'
        },
        {
            name: 'gps_y'
        },
        {
            name: 'status',
            type: 'string'
        },
        {
            name: 'user_id',
            type: 'int'
        }
    ],
    
    associations:[{
            type :'hasMany',
            model: 'Holo.model.SpotDescription',
            autoLoad : false,
            name: 'spotdescriptions',
            foreignKey:'spot_id'
        },
        //{
        //   type: 'belongsTo',
        //   model: 'Holo.model.User',
        //   foreignKey:'user_id'
        //}
    ],
     
    proxy: {
        type: 'ajax',
        api: {
            create: 'database/controller.php?MODEL=spot&ACTION=ADD',
            read: 'database/controller.php?MODEL=spot&ACTION=LST',
            update: 'database/controller.php?MODEL=spot&ACTION=UPD',
            destroy: 'database/controller.php?MODEL=spot&ACTION=DEL'
        },
        reader: {
            type: 'json',
            root: 'data'
        },
        
        writer : {
            type: 'json',
        	allowSingle  : false,
        	root: 'data',
        	encode : true
        }
    }
});